package org.huntaway.kernel.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimesTools {
	static String STY_24="";
	/**
	 * @param str
	 * @param dateStyle
	 * @return
	 * @throws RadException
	 */
	public Date str2Time(String str, String dateStyle) throws NutException {
		SimpleDateFormat daSty = new SimpleDateFormat(dateStyle);
		try {
			return daSty.parse(str);
		} catch (ParseException e) {
			throw new NutException(e);
		}
	}

	/**
	 * @param date
	 * @param dateStyle
	 * @return
	 * @throws RadException
	 */
	public String Time2Str(Date date, String dateStyle) {
		SimpleDateFormat daSty = new SimpleDateFormat(dateStyle);
		return daSty.format(date);
	}

	/**
	 * @param dateStyle
	 * @return
	 */
	public String nowDate(String dateStyle) {
		SimpleDateFormat daSty = new SimpleDateFormat(dateStyle);
		return daSty.format(new Date());
	}
}
